var rootPath = getRootPath();

$(function() {
	var oriState = $("#oriState").val();
	$("#state > option").each(function() {
		if($(this).val() == oriState) {
			$(this).prop("selected","selected");
		}
	});
	
	$("#realNameAuthEditForm").validate({
		rules : {
			state : {
				required : true
			},
			checkResult : {
				required : true
			}
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			var uid = $("#uid").val();
			$("#realNameAuthEditForm").ajaxSubmit({
				url : rootPath + '/realNameAuth/checkAuth',
				type : 'POST',
				dataType : 'json',
				success : function(data) {
					if("0000" == data.returnCode) {						
						layer.msg('更新成功!',{icon:1,time:1000},function() {
//							parent.window.location.href = rootPath + '/realNameAuthPage';
							var index = parent.layer.getFrameIndex(window.name);
							parent.layer.close(index);
							parent.$("#searchRealNameAuth").click();
						});
					} else {
						layer.alert(data.returnMessage);
					}
				},
				error: function (jqXHR, textStatus, errorThrown) {
					layer.msg('error!!!',{icon:1,time:1000});
				}
			});
			return false;
		}
	});
});